package service

import (
	"context"
	"fmt"
	"go_es/server/global"
)

type ElasticService struct {}


//Put 上传数据 (结构体只能上传单条数据)
func (Es *ElasticService) Put(index string, bodyJSON interface{}) bool {
	_, err := global.GVA_ES.Index().
		Index(index).
		BodyJson(bodyJSON).
		Do(context.Background())
	if err != nil {
		// Handle error
		fmt.Sprintf("<Put> some error occurred when put.  err:%s", err.Error())
		return false
	}
	return true
}

//func (Es *ElasticService) BatchPut(index string,)  {
//
//}